home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume11 / netdata < prev    next >
Encoding:
Internet Message Format  |  1987-10-03  |  20.9 KB

  1. Subject:  v11i089:  Transfer data (and mail) between SYSV and CMS
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: Gary Mills <mills@cc.uofm.cdn>
  7. Posting-number: Volume 11, Issue 89
  8. Archive-name: diskdump
  9.  
  10. [  These programs are used to transfer files (and files containing mail
  11.    messages) between Unix (System V, but porting to BSD should be easy
  12.    enough) and CMS, which I am led to believe is an operating system
  13.    from the people responsible for the promulgation of MS-DOS.  --r$  ]
  14.  
  15. ==================
  16. #! /bin/sh
  17. # This is a shell archive, meaning:
  18. # 1.  Remove everything above the #! /bin/sh line.
  19. # 2.  Save the resulting text in a file
  20. # 3.  Execute the file with /bin/sh (not csh) to create the files:
  21. #
  22. #        README
  23. #        diskdump.mk
  24. #        netdata.mk
  25. #        diskdump.man
  26. #        netdata.man
  27. #        sendfile.man
  28. #        diskdump.c
  29. #        netdata.c
  30. #        sendfile
  31. #
  32. if test -f 'README'
  33. then
  34.     echo shar: will not over-write existing file "'README'"
  35. else
  36. echo extracting "'README'"
  37. sed 's/^X//' >README <<'SHAR_EOF'
  38. XDiskdump.c and netdata.c are written in C for System V.  I use them
  39. Xas part of a mail gateway between CDNnet and Bitnet.  They are
  40. Xuseful here because we run UTS unix under VM.  The programs also
  41. Xcompile and run on our MVS system and are useful as a way to get
  42. Xfiles with lines longer than 80 characters out on Bitnet.
  43. X
  44. X-Gary Mills-         <mills@cc.uofm.cdn>
  45. SHAR_EOF
  46. if test     355 -ne "`wc -c < 'README'`"
  47. then
  48.     echo shar: error transmitting "'README'" '(should have been     355 characters)'
  49. fi
  50. fi
  51. if test -f 'diskdump.mk'
  52. then
  53.     echo shar: will not over-write existing file "'diskdump.mk'"
  54. else
  55. echo extracting "'diskdump.mk'"
  56. sed 's/^X//' >diskdump.mk <<'SHAR_EOF'
  57. X# %W% %G% %U% - Uofmcc/UTS
  58. XSHELL = /bin/sh
  59. XI = /usr/include
  60. X
  61. Xdiskdump: diskdump.c    $I/stdio.h 
  62. X    $(CC) $(CFLAGS) -o diskdump diskdump.c -la
  63. X
  64. Xinstall: diskdump
  65. X    /etc/install diskdump
  66. Xclean:
  67. Xclobber: clean
  68. X    -rm -f diskdump
  69. SHAR_EOF
  70. if test     219 -ne "`wc -c < 'diskdump.mk'`"
  71. then
  72.     echo shar: error transmitting "'diskdump.mk'" '(should have been     219 characters)'
  73. fi
  74. fi
  75. if test -f 'netdata.mk'
  76. then
  77.     echo shar: will not over-write existing file "'netdata.mk'"
  78. else
  79. echo extracting "'netdata.mk'"
  80. sed 's/^X//' >netdata.mk <<'SHAR_EOF'
  81. X# %W% %G% %U% - Uofmcc/UTS
  82. XSHELL = /bin/sh
  83. XI = /usr/include
  84. X
  85. Xnetdata: netdata.c    $I/stdio.h 
  86. X    $(CC) $(CFLAGS) -o netdata netdata.c -la
  87. X
  88. Xinstall: netdata
  89. X    /etc/install netdata
  90. Xclean:
  91. Xclobber: clean
  92. X    -rm -f netdata
  93. SHAR_EOF
  94. if test     212 -ne "`wc -c < 'netdata.mk'`"
  95. then
  96.     echo shar: error transmitting "'netdata.mk'" '(should have been     212 characters)'
  97. fi
  98. fi
  99. if test -f 'diskdump.man'
  100. then
  101.     echo shar: will not over-write existing file "'diskdump.man'"
  102. else
  103. echo extracting "'diskdump.man'"
  104. sed 's/^X//' >diskdump.man <<'SHAR_EOF'
  105. X.TH DISKDUMP 1 "LOCAL"
  106. X.SH NAME
  107. Xdiskdump \- produce CMS disk dump file
  108. X.SH SYNOPSIS
  109. Xdiskdump [-n <name> -t <type> <file>]
  110. X.SH DESCRIPTION
  111. XDiskdump converts a standard text file into CMS disk dump format
  112. Xand writes it to standard output as a
  113. Xstream of 80-byte binary and EBCDIC card images.
  114. XThis allows a text file with lines longer than 80 characters to be
  115. X"punched" to a CMS user.
  116. XIf <file> is not specified, standard input is used.
  117. XThe command line options are:
  118. X.TP 12
  119. X-n <name>
  120. XSpecifies an internal filename for the CMS file.
  121. XThe default is "MAILER".
  122. X.TP 12
  123. X-t <type>
  124. XSpecifies an internal filetype for the CMS file.
  125. XThe default is "MAIL".
  126. X.SH EXAMPLES
  127. XSend a file to user MAILER on node UOFMCC:
  128. X.ti+8n
  129. Xdiskdump hello.c | lp -db -o"-r -v uofmcc.mailer"
  130. X.SH SEE ALSO
  131. Xlp(1), netdata(1x)
  132. X.SH BUGS
  133. XDiskdump will fold input lines longer than 254 characters.
  134. XIt will not handle binary files.
  135. XThe CMS file produced is always format V.
  136. XThe ASCII to EBCDIC translation may not conform to what is expected
  137. Xon the receiving system.
  138. SHAR_EOF
  139. if test    1025 -ne "`wc -c < 'diskdump.man'`"
  140. then
  141.     echo shar: error transmitting "'diskdump.man'" '(should have been    1025 characters)'
  142. fi
  143. fi
  144. if test -f 'netdata.man'
  145. then
  146.     echo shar: will not over-write existing file "'netdata.man'"
  147. else
  148. echo extracting "'netdata.man'"
  149. sed 's/^X//' >netdata.man <<'SHAR_EOF'
  150. X.TH NETDATA 1 "LOCAL"
  151. X.SH NAME
  152. Xnetdata \- produce CMS netdata file
  153. X.SH SYNOPSIS
  154. Xnetdata [-n <name> -t <type> -s <size> -u <orig_user> -d <dest_node> -v <dest_user> <file>]
  155. X.SH DESCRIPTION
  156. XNetdata converts a standard text file into CMS netdata format
  157. Xand writes it to standard output
  158. Xas a stream of 80-byte binary and EBCDIC card images.
  159. XThis allows a text file with lines longer than 80 characters to be
  160. X"punched" to a CMS or TSO/E user.
  161. XIf <file> is not specified, standard input is used.
  162. XThe command line options are:
  163. X.TP 12
  164. X-n <name>
  165. XSpecifies an internal file name for the CMS file.
  166. XThe default is "MAILER".
  167. X.TP 12
  168. X-t <type>
  169. XSpecifies an internal file type for the CMS file.
  170. XThe default is "MAIL".
  171. X.TP 12
  172. X-s <size>
  173. XSpecifies the approximate size of the file, for space allocation
  174. Xpurposes on the receiving system.
  175. XThis option is only needed when the input is standard input.
  176. XThe default is 2048 bytes.
  177. X.TP 12
  178. X-u <orig_user>
  179. XSpecifies the origin user name.
  180. XThe default is "MAILER".
  181. X.TP 12
  182. X-d <dest_node>
  183. XSpecifies the destination node name.
  184. XThe default is the local node.
  185. X.TP 12
  186. X-v <dest_user>
  187. XSpecifies the destination user name.
  188. XThe default is "MAILER".
  189. X.SH EXAMPLES
  190. XSend a file to user MAILER on node UOFMCC:
  191. X.ti+2n
  192. Xnetdata -d uofmcc hello.c | lp -db -o"-r -v uofmcc.mailer"
  193. X.SH SEE ALSO
  194. Xlp(1), diskdump(1x)
  195. X.SH BUGS
  196. XNetdata will fold input lines longer than 253 characters.
  197. XIt will not handle binary files.
  198. XThe CMS file produced is always sequental and format V.
  199. XSpecifying wrong destination node or user names may confuse the
  200. Xreceiving system.
  201. XThe ASCII to EBCDIC translation may not conform to what is expected
  202. Xon the receiving system.
  203. SHAR_EOF
  204. if test    1645 -ne "`wc -c < 'netdata.man'`"
  205. then
  206.     echo shar: error transmitting "'netdata.man'" '(should have been    1645 characters)'
  207. fi
  208. fi
  209. if test -f 'sendfile.man'
  210. then
  211.     echo shar: will not over-write existing file "'sendfile.man'"
  212. else
  213. echo extracting "'sendfile.man'"
  214. sed 's/^X//' >sendfile.man <<'SHAR_EOF'
  215. X.TH SENDFILE 1 "LOCAL"
  216. X.SH NAME
  217. Xsendfile \- send a file to VM or to another node via RSCS
  218. X.SH SYNOPSIS
  219. Xsendfile [-v <user> -d <node> -o -p] <file>
  220. X.SH DESCRIPTION
  221. XSendfile reads a text file, converts it to EBCDIC, and sends it
  222. Xto a VM user or, via RSCS, to a user at another NJE node.
  223. XThe default file format is CMS NETDATA.
  224. XThe command line options are:
  225. X.TP 12
  226. X-d <node>
  227. XSpecifies the destination node name.
  228. XThe default is the local node.
  229. X.TP 12
  230. X-v <user>
  231. XSpecifies the destination user name.
  232. XThe default is taken from the environment variable $VMID.
  233. X.TP 12
  234. X-o
  235. XThe file will be sent in CMS DISK DUMP format.
  236. X.TP 12
  237. X-p
  238. XThe file will be sent in CMS PUNCH format.
  239. X.SH EXAMPLES
  240. XSend a file to user MILLS on node UOFMCC:
  241. X.ti+2n
  242. Xsendfile -d uofmcc -v mills hello.c
  243. X.SH SEE ALSO
  244. Xlp(1), diskdump(1x), netdata(1x)
  245. X.SH BUGS
  246. XSendfile will not handle binary files.
  247. XThe CMS file produced is always sequental and format V.
  248. XThe ASCII to EBCDIC translation may not conform to what is expected
  249. Xon the receiving system.
  250. SHAR_EOF
  251. if test    1003 -ne "`wc -c < 'sendfile.man'`"
  252. then
  253.     echo shar: error transmitting "'sendfile.man'" '(should have been    1003 characters)'
  254. fi
  255. fi
  256. if test -f 'diskdump.c'
  257. then
  258.     echo shar: will not over-write existing file "'diskdump.c'"
  259. else
  260. echo extracting "'diskdump.c'"
  261. sed 's/^X//' >diskdump.c <<'SHAR_EOF'
  262. X/* diskdump.c:    convert    text file to CMS disk dump format */
  263. X/*        output is a stream of 80-byte card images */
  264. X
  265. X/* Author:   Gary Mills    <mills@cc.uofm.cdn>          */
  266. X/*            <mills@uofmcc.bitnet>          */
  267. X
  268. X/* Compilation Switches:                  */
  269. X/*    MVS:    Waterloo C v1.3    for MVS              */
  270. X/*    default:  Amdahl UTS Unix System V          */
  271. X
  272. X/* #define MVS       1 */
  273. X#include <stdio.h>
  274. X#ifdef    MVS
  275. X#define    ATE(c)    (c)
  276. X#else
  277. Xextern char atetab[128];    /* ASCII to EBCDIC translation table */
  278. X
  279. X#define    ATE(c)    atetab[c]
  280. X#endif
  281. X#define    NUL    '\0'
  282. X#define    SIZBUF    256
  283. X#define    CMSV    struct cmsrec
  284. XCMSV
  285. X    {
  286. X    char dd_id[1];    /* 0x02    */
  287. X    char dd_cms[3];    /* "CMS" */
  288. X    char dd_fmt[1];    /* record format */
  289. X    char dd_data[50];    /* text    */
  290. X    char dd_blk[2];    /* block count */
  291. X    char dd_fn[8];    /* file    name */
  292. X    char dd_ft[8];    /* file    type */
  293. X    char dd_fm[3];    /* file    mode */
  294. X    char dd_seq[4];    /* sequence */
  295. X    };
  296. X
  297. Xstatic char    inbuf[SIZBUF];
  298. Xstatic CMSV    rec;
  299. Xstatic int    recn, blkn;
  300. Xstatic int    datax;
  301. Xstatic FILE    *ofile;
  302. X
  303. Xmain(argc, argv) int argc; char    **argv;
  304. X    {
  305. X    int    n, num,    max;
  306. X    char *inpt;
  307. X    FILE *ifile;
  308. X    char c;
  309. X    char *fname, *ftype, *pgm;
  310. X
  311. X    ifile = stdin;
  312. X    ofile = stdout;
  313. X    fname = "mailer";
  314. X    ftype = "mail";
  315. X    pgm    = *argv++;
  316. X    --argc;
  317. X    while ( argc )
  318. X    {
  319. X    if ( **argv == '-' )
  320. X        {
  321. X        c =    tolower( (*argv)[1] );
  322. X        ++argv;
  323. X        --argc;
  324. X        if ( argc )
  325. X        {
  326. X        --argc;
  327. X        if ( c == 'n' )
  328. X            fname = *argv++;
  329. X        else if    ( c == 't' )
  330. X            ftype = *argv++;
  331. X        else
  332. X            {
  333. X            ++argc;
  334. X            break;
  335. X            }
  336. X        }
  337. X        else
  338. X        {
  339. X        ++argc;
  340. X        break;
  341. X        }
  342. X        }
  343. X    else
  344. X        {
  345. X        if ( ( ifile = fopen(*argv,    "r") ) == NULL )
  346. X        {
  347. X        fprintf(stderr,    "%s: cannot open %s\n",    pgm, *argv);
  348. X        return(1);
  349. X        }
  350. X        --argc;
  351. X        break;
  352. X        }
  353. X    }
  354. X    if ( argc )
  355. X    {
  356. X    fprintf(stderr,    "usage:    %s [-n name -t type file]\n", pgm);
  357. X    return(1);
  358. X    }
  359. X#ifdef    MVS
  360. X    ofile = fopen("SYSUT2 ( bin", "w");
  361. X#endif
  362. X    num    = max =    0;
  363. X    iniout(fname, ftype);
  364. X    while ( n =    igets(ifile) )
  365. X    {
  366. X    ++num;
  367. X    while (    n > 1 && inbuf[n-1] == ' ' )
  368. X        --n;
  369. X    inbuf[n] = NUL;
  370. X    if ( n > max )
  371. X        max    = n;
  372. X    inpt = inbuf;
  373. X    oput(n/256);
  374. X    oput(n&255);
  375. X    while (    n = *inpt++ )
  376. X        {
  377. X        oput( ATE(n) );
  378. X        }
  379. X    }
  380. X    finout(num,    max);
  381. X    if ( ifile != stdin    )
  382. X    fclose(ifile);
  383. X    return 0;
  384. X    }
  385. X
  386. X/* get input line, expanding tabs and padding null lines */
  387. Xigets(fp) FILE *fp;
  388. X    {
  389. X    int    c, col;
  390. X    col    = 0;
  391. X    while ( ( c    = getc(fp) ) !=    EOF )
  392. X    {
  393. X    if ( c == '\t' )
  394. X        do
  395. X        inbuf[col++] = ' ';
  396. X        while ( col    < SIZBUF-1 && col % 8 );
  397. X    else if    ( c == '\n' )
  398. X        {
  399. X        if ( col ==    0 )
  400. X        inbuf[col++] = ' ';
  401. X        break;
  402. X        }
  403. X    else
  404. X        {
  405. X        inbuf[col++] = c;
  406. X        }
  407. X    if ( !(    col < SIZBUF-1 ) )
  408. X        break;
  409. X    }
  410. X    inbuf[col] = NUL;
  411. X    return col;
  412. X    }
  413. X
  414. X/* initialize output */
  415. Xiniout(sn, st) char *sn, *st;
  416. X    {
  417. X    recn = blkn    = 1;
  418. X    datax = 0;
  419. X    rec.dd_id[0] = 0x02;
  420. X    mncopy(rec.dd_cms, "CMS", 3);
  421. X    rec.dd_fmt[0] = ATE('V');
  422. X    memset(rec.dd_data,    0, 50);
  423. X    mhalf(rec.dd_blk, blkn);
  424. X    memset(rec.dd_fn, ATE(' '),    19);
  425. X    mncopy(rec.dd_seq, "0001", 4);
  426. X    mncopy(rec.dd_fn, sn, 8);
  427. X    mncopy(rec.dd_ft, st, 8);
  428. X    mncopy(rec.dd_fm, "A1", 3);
  429. X    }
  430. X
  431. X/* finalize output */
  432. Xfinout(n, m) int n, m;
  433. X    {
  434. X    oflush();
  435. X    oflush();
  436. X    rec.dd_fmt[0] = ATE('N');
  437. X    mhalf(&rec.dd_data[0], n+1);    /* write pointer (number) */
  438. X    mhalf(&rec.dd_data[2], 1);        /* read    pointer    (number) */
  439. X    mncopy(&rec.dd_data[4], "A1", 2);    /* file    mode */
  440. X    mhalf(&rec.dd_data[6], n);        /* item    count (number) */
  441. X    rec.dd_data[10] = ATE('V');        /* variable flag */
  442. X    mhalf(&rec.dd_data[14], m);        /* max item length */
  443. X    mhalf(&rec.dd_data[16], blkn);    /* number of blocks */
  444. X    mhalf(&rec.dd_data[26], blkn);    /* alternate number of blocks */
  445. X    mhalf(&rec.dd_data[30], n);        /* alternate item count    */
  446. X    oflush();
  447. X    }
  448. X
  449. X/* add a byte to output    */
  450. Xoput(c)    char c;
  451. X    {
  452. X    rec.dd_data[datax++] = c;
  453. X    if ( datax >= 50 )
  454. X    {
  455. X    oflush();
  456. X    datax =    0;
  457. X    }
  458. X    }
  459. X
  460. X/* write and re-initialize record */
  461. Xoflush()
  462. X    {
  463. X    int    n, r;
  464. X    for    ( n = 0; n < 80; ++n )
  465. X    putc(rec.dd_id[n], ofile);
  466. X    memset(rec.dd_data,    0, 50);
  467. X    if ( recn %    16 == 0    )
  468. X    ++blkn;
  469. X    ++recn;
  470. X    mhalf(rec.dd_blk, blkn);
  471. X    r =    recn;
  472. X    for    ( n = 3; n >= 0; --n )
  473. X    {
  474. X    rec.dd_seq[n] =    ATE(r %    10 + '0');
  475. X    r = r /    10;
  476. X    }
  477. X    }
  478. X
  479. X/* copy    string to memory in upper case,    not including NUL */
  480. Xmncopy(s1, s2, n) char *s1, *s2; int n;
  481. X    {
  482. X    while ( --n    >= 0 &&    *s2 )
  483. X    *s1++ =    ATE( toupper(*s2++) );
  484. X    }
  485. X
  486. X/* copy    two-byte integer to memory */
  487. Xmhalf(s, n) char *s; int n;
  488. X    {
  489. X    s[0] = n/256;
  490. X    s[1] = n&255;
  491. X    }
  492. X
  493. X/**/
  494. SHAR_EOF
  495. if test    4585 -ne "`wc -c < 'diskdump.c'`"
  496. then
  497.     echo shar: error transmitting "'diskdump.c'" '(should have been    4585 characters)'
  498. fi
  499. fi
  500. if test -f 'netdata.c'
  501. then
  502.     echo shar: will not over-write existing file "'netdata.c'"
  503. else
  504. echo extracting "'netdata.c'"
  505. sed 's/^X//' >netdata.c <<'SHAR_EOF'
  506. X/* netdata.c:  convert text file to CMS    netdata    format      */
  507. X/*           output is a stream of 80-byte card images  */
  508. X
  509. X/* Author:   Gary Mills    <mills@cc.uofm.cdn>          */
  510. X/*            <mills@uofmcc.bitnet>          */
  511. X
  512. X/* Compilation Switches:                  */
  513. X/*    MVS:    Waterloo C v1.3    for MVS              */
  514. X/*    default:  Amdahl UTS Unix System V          */
  515. X
  516. X/* #define MVS       1 */
  517. X#include <stdio.h>
  518. X#include <time.h>
  519. X#ifdef    MVS
  520. X#define    ATE(c)    (c)
  521. X#else
  522. X#include <sys/types.h>
  523. X#include <sys/stat.h>
  524. Xextern long time();
  525. Xextern struct tm *gmtime();
  526. Xextern char atetab[128];    /* ASCII to EBCDIC translation table */
  527. X
  528. X#define    ATE(c)    atetab[c]
  529. X#endif
  530. X#define    NUL    '\0'
  531. X#define    TCAST    (long *)
  532. X#define    SIZBUF    254
  533. X#define    SIZREC    255
  534. X#ifdef    MVS
  535. X#define    ONODE    "UOFMCC"
  536. X#else
  537. X#define    ONODE    "UOFMCCX"
  538. X#endif
  539. X
  540. X/* control record identifiers */
  541. X#define    INMR01    "INMR01"
  542. X#define    INMR02    "INMR02"
  543. X#define    INMR03    "INMR03"
  544. X#define    INMR06    "INMR06"
  545. X
  546. X/* text    unit keys */
  547. X#define    INMLRECL 0x0042
  548. X#define    INMFNODE 0x1011
  549. X#define    INMFUID     0x1012
  550. X#define    INMTNODE 0x1001
  551. X#define    INMTUID     0x1002
  552. X#define    INMFTIME 0x1024
  553. X#define    INMNUMF     0x102f
  554. X#define    INMSIZE     0x102c
  555. X#define    INMDSORG 0x003c
  556. X#define    INMUTILN 0x1028
  557. X#define    INMRECFM 0x0049
  558. X#define    INMTERM     0x0028
  559. X#define    INMDSNAM 0x0002
  560. X#define    INMFFM     0x102d
  561. X#define    INMLCHG     0x1021
  562. X
  563. Xstatic char    inbuf[SIZBUF];
  564. Xstatic char    rec[SIZREC];
  565. Xstatic char    tvalue[21];
  566. X#ifndef    MVS
  567. Xstatic struct    stat sbuf;
  568. X#endif
  569. Xstatic int    count;    /* output char count */
  570. Xstatic FILE    *ofile;    /* output file */
  571. X
  572. Xchar *acunit(),    *abunit(), *acfield(), *inirec(), *membin();
  573. X
  574. Xmain(argc, argv) int argc; char    **argv;
  575. X    {
  576. X    int    n;
  577. X    char *pend,    *pstar;
  578. X    FILE *ifile;
  579. X    char c;
  580. X    char *ouser, *dnode, *duser;
  581. X    char *tcurr, *tlast;
  582. X    char *fname, *ftype, *pgm;
  583. X    int    fsize, maxl;
  584. X    long tbuf;
  585. X    struct tm *tpt;
  586. X
  587. X#ifdef MVS
  588. X    tpt    = localtime();
  589. X#else
  590. X    tbuf = time( TCAST 0 );
  591. X    tpt    = gmtime(&tbuf);
  592. X#endif
  593. X    sprintf(tvalue, "%04d%02d%02d%02d%02d%02d%06d",
  594. X    tpt->tm_year+1900, tpt->tm_mon+1, tpt->tm_mday,
  595. X    tpt->tm_hour, tpt->tm_min, tpt->tm_sec,    0);
  596. X    tcurr = tlast = tvalue;
  597. X    ifile = stdin;
  598. X    ofile = stdout;
  599. X    ouser = duser = fname = "MAILER";
  600. X    dnode = ONODE;
  601. X    ftype = "MAIL";
  602. X    fsize = 0x0800;
  603. X    maxl = SIZBUF-1;
  604. X
  605. X    pgm    = *argv++;
  606. X    --argc;
  607. X    while ( argc )
  608. X    {
  609. X    if ( **argv == '-' )
  610. X        {
  611. X        c =    tolower( (*argv)[1] );
  612. X        ++argv;
  613. X        --argc;
  614. X        if ( argc )
  615. X        {
  616. X        --argc;
  617. X        if ( c == 'n' )
  618. X            fname = *argv++;
  619. X        else if    ( c == 't' )
  620. X            ftype = *argv++;
  621. X        else if    ( c == 'u' )
  622. X            ouser = *argv++;
  623. X        else if    ( c == 'd' )
  624. X            dnode = *argv++;
  625. X        else if    ( c == 'v' )
  626. X            duser = *argv++;
  627. X        else if    ( c == 's' )
  628. X            fsize = atoi(*argv++);
  629. X        else
  630. X            {
  631. X            ++argc;
  632. X            break;
  633. X            }
  634. X        }
  635. X        else
  636. X        {
  637. X        ++argc;
  638. X        break;
  639. X        }
  640. X        }
  641. X    else
  642. X        {
  643. X        if ( ( ifile = fopen(*argv,    "r") ) != NULL )
  644. X        {
  645. X#ifndef    MVS
  646. X        if ( 0 == fstat( fileno(ifile),    &sbuf) )
  647. X            fsize = sbuf.st_size;
  648. X#endif
  649. X        }
  650. X        else
  651. X        {
  652. X        fprintf(stderr,    "%s: cannot open %s\n",    pgm, *argv);
  653. X        return(1);
  654. X        }
  655. X        --argc;
  656. X        break;
  657. X        }
  658. X    }
  659. X    if ( argc )
  660. X    {
  661. X    fprintf(stderr,    "usage:    %s [-n name -t type -u orig_user\n", pgm);
  662. X    fprintf(stderr,    "    -d dest_node -v    dest_user -s size file]\n");
  663. X    return(1);
  664. X    }
  665. X#ifdef MVS
  666. X    ofile = fopen("SYSUT2 ( bin", "w");
  667. X    if ( ofile == NULL )
  668. X    return 1;
  669. X#endif
  670. X
  671. X    pend = inirec(rec, INMR01, -1);    /* header */
  672. X    pend = abunit(pend,    INMLRECL, 80, 2);
  673. X    pend = acunit(pend,    INMFNODE, ONODE);
  674. X    pend = acunit(pend,    INMFUID, ouser);
  675. X    pend = acunit(pend,    INMTNODE, dnode);
  676. X    pend = acunit(pend,    INMTUID, duser);
  677. X    pend = acunit(pend,    INMFTIME, tcurr);
  678. X    pend = abunit(pend,    INMNUMF, 1, 4);
  679. X    finrec(rec,    pend);
  680. X
  681. X    pend = inirec(rec, INMR02, 1);    /* output utility */
  682. X    pend = abunit(pend,    INMSIZE, fsize,    8);
  683. X    pend = abunit(pend,    INMDSORG, 0x4000, 2);
  684. X    pend = abunit(pend,    INMLRECL, maxl,    4);
  685. X    pend = acunit(pend,    INMUTILN, "INMCOPY");
  686. X    pend = abunit(pend,    INMRECFM, 0x0002, 2);
  687. X    pstar = pend;
  688. X    pend = acunit(pend,    INMDSNAM, "A");
  689. X    pend = acfield(pend, fname);
  690. X    pend = acfield(pend, ftype);
  691. X    pstar[3] = 3;
  692. X    pend = acunit(pend,    INMFFM,    "1");
  693. X    pend = acunit(pend,    INMLCHG, tlast);
  694. X    finrec(rec,    pend);
  695. X
  696. X    pend = inirec(rec, INMR03, -1);    /* input data */
  697. X    pend = abunit(pend,    INMSIZE, fsize,    8);
  698. X    pend = abunit(pend,    INMDSORG, 0x4000, 2);
  699. X    pend = abunit(pend,    INMLRECL, 80, 2);
  700. X    pend = abunit(pend,    INMRECFM, 0x0001, 2);
  701. X    finrec(rec,    pend);
  702. X
  703. X    while ( n =    igets(ifile) )        /* data    records    */
  704. X    {
  705. X    while (    n > 1 && inbuf[n-1] == ' ' )
  706. X        --n;
  707. X    inbuf[n] = NUL;
  708. X    odata(n, inbuf);
  709. X    }
  710. X
  711. X    pend = inirec(rec, INMR06, -1);    /* trailer */
  712. X    finrec(rec,    pend);
  713. X
  714. X    finout();
  715. X    return 0;
  716. X    }
  717. X
  718. X/* get input line, expanding tabs and padding null lines */
  719. Xigets(fp) FILE *fp;
  720. X    {
  721. X    int    c, col;
  722. X    col    = 0;
  723. X    while ( ( c    = getc(fp) ) !=    EOF )
  724. X    {
  725. X    if ( c == '\t' )
  726. X        do
  727. X        inbuf[col++] = ' ';
  728. X        while ( col    < SIZBUF-1 && col % 8 );
  729. X    else if    ( c == '\n' )
  730. X        {
  731. X        if ( col ==    0 )
  732. X        inbuf[col++] = ' ';
  733. X        break;
  734. X        }
  735. X    else
  736. X        {
  737. X        inbuf[col++] = c;
  738. X        }
  739. X    if ( !(    col < SIZBUF-1 ) )
  740. X        break;
  741. X    }
  742. X    inbuf[col] = NUL;
  743. X    return col;
  744. X    }
  745. X
  746. X/* initialize control record */
  747. Xchar *inirec(pt, s, n) char *pt, *s; int n;
  748. X    {
  749. X    *pt++ = 0;        /* length bythe    */
  750. X    *pt++ = 0xe0;    /* flag    byte */
  751. X    while ( *s )    /* identifier */
  752. X    *pt++ =    ATE( toupper(*s++) );
  753. X    if ( n > 0 )    /* number of files */
  754. X    pt = membin(pt,    n, 4);
  755. X    return pt;
  756. X    }
  757. X
  758. X/* finalize control record */
  759. Xfinrec(pt, pe) char *pt, *pe;
  760. X    {
  761. X    *pt    = pe - pt;    /* length byte */
  762. X    while ( pt < pe )    /* record */
  763. X    {
  764. X    putc(*pt, ofile);
  765. X    ++pt;
  766. X    ++count;
  767. X    }
  768. X    }
  769. X
  770. X/* add a binary    text unit */
  771. Xchar *abunit(pt, k, v, n) char *pt; int    k, v, n;
  772. X    {
  773. X    pt = membin(pt, k, 2);    /* key */
  774. X    pt = membin(pt, 1, 2);    /* count */
  775. X    pt = membin(pt, n, 2);    /* length */
  776. X    pt = membin(pt, v, n);    /* value */
  777. X    return pt;
  778. X    }
  779. X
  780. X/* add a character text    unit */
  781. Xchar *acunit(pt, k, s) char *pt; int k;    char *s;
  782. X    {
  783. X    pt = membin(pt, k, 2);    /* key */
  784. X    pt = membin(pt, 1, 2);    /* count */
  785. X    pt = membin(pt, strlen(s), 2);    /* length */
  786. X    while ( *s )        /* value */
  787. X    *pt++ =    ATE( toupper(*s++) );
  788. X    return pt;
  789. X    }
  790. X
  791. X/* add a character field */
  792. Xchar *acfield(pt, s) char *pt, *s;
  793. X    {
  794. X    pt = membin(pt, strlen(s), 2);    /* length */
  795. X    while ( *s )        /* value */
  796. X    *pt++ =    ATE( toupper(*s++) );
  797. X    return pt;
  798. X    }
  799. X
  800. X/* add a binary    item */
  801. Xchar *membin(pt, v, n) char *pt; int v,    n;
  802. X    {
  803. X    char *pe;
  804. X    pe = pt + n;
  805. X    while ( --pe >= pt )
  806. X    {
  807. X    *pe = v;
  808. X    v = v /    256;
  809. X    }
  810. X    return pt +    n;
  811. X    }
  812. X
  813. X/* write a data    record */
  814. Xodata(n, pt) int n; char *pt;
  815. X    {
  816. X    char *pe;
  817. X    pe = pt + n;
  818. X    putc(n+2, ofile);  /* length byte */
  819. X    putc(0xc0, ofile); /* flag byte */
  820. X    count = count + 2;
  821. X    while ( pt < pe )    /* data    */
  822. X    {
  823. X    putc(ATE(*pt), ofile);
  824. X    ++pt;
  825. X    ++count;
  826. X    }
  827. X    }
  828. X
  829. X/* pad last record */
  830. Xfinout()
  831. X    {
  832. X    while ( count % 80 )
  833. X    {
  834. X    putc(0,    ofile);
  835. X    ++count;
  836. X    }
  837. X    }
  838. X
  839. X/**/
  840. SHAR_EOF
  841. if test    6988 -ne "`wc -c < 'netdata.c'`"
  842. then
  843.     echo shar: error transmitting "'netdata.c'" '(should have been    6988 characters)'
  844. fi
  845. fi
  846. if test -f 'sendfile'
  847. then
  848.     echo shar: will not over-write existing file "'sendfile'"
  849. else
  850. echo extracting "'sendfile'"
  851. sed 's/^X//' >sendfile <<'SHAR_EOF'
  852. X:
  853. X# Send a file to a user at another node
  854. XV="$VMID"
  855. XD=""
  856. XF="NETDATA"
  857. XCMD=$0
  858. XL="/usr/cserv/mills/sendfile"
  859. XSKIP=""
  860. X
  861. Xfor ARG do
  862. X    if [ "$SKIP" ]; then
  863. X    SKIP=""
  864. X    else
  865. X    case $ARG in
  866. X    -v) shift; V="$1"; SKIP="Y"; shift;;
  867. X    -d) shift; D="$1"; SKIP="Y"; shift;;
  868. X    -o) shift; F="DISK DUMP";;
  869. X    -p) shift; F="PUNCH";;
  870. X    -*) echo $CMD: invalid option \'$ARG\'; exit 1;;
  871. X        esac
  872. X    fi
  873. Xdone
  874. X
  875. Xif test ! -r $1; then
  876. X    echo $CMD: file $1 is not readable;
  877. X    exit 1;
  878. Xfi
  879. X
  880. Xif [ x"$D" = "x" ]; then
  881. X    X="$V";D="UOMFCCX";echo Sending file $1 to $V in $F format.;
  882. Xelse
  883. X    X="$D"."$V";echo Sending file $1 to "$V"@"$D" in $F format.;
  884. Xfi
  885. X
  886. Xcase $F in
  887. X    D*) $L/diskdump -n $LOGNAME $1 |
  888. X    lp -db -o"-r -v $X -f $LOGNAME";;
  889. X    N*) $L/netdata -n $LOGNAME -v $V -d $D $1 |
  890. X    lp -db -o"-r -v $X -f $LOGNAME";;
  891. X    *) lp -db -o"-v $X -f $LOGNAME" < $1;;
  892. Xesac
  893. SHAR_EOF
  894. if test     840 -ne "`wc -c < 'sendfile'`"
  895. then
  896.     echo shar: error transmitting "'sendfile'" '(should have been     840 characters)'
  897. fi
  898. fi
  899. # end of shell archive
  900. exit 0
  901.  
  902.